package com.song.service.impl;

import com.song.vo.SecurityUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Author Klys
 * @Date 2023/6/5 17:23
 * @Description
 * @Version 1.0
 */
@Service
@Slf4j
public class UserServiceImpl implements UserDetailsService {

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        if (!StringUtils.hasText(username)) {//用户名为空
            throw new UsernameNotFoundException("用户名不存在");
        }
        if (!username.equals("klys")) {
            throw new UsernameNotFoundException("用户名不正确");
        }
        SecurityUser securityUser = new SecurityUser();
        return securityUser;
    }
}
